import request from "../utils/request.js";
// wx登录
const loginUrl = '/api/users/wechat/login';
const agreementUrl = '/platforms/user-agreement';
const privacyUrl = '/platforms/privacy-policy';


// 用户信息
const userInfo = '/api/users/infos';
// 修改头像
const changeAvater = '/api/users/avatars/change';
// 修改昵称
const editNameUrl = '/api/users/nicknames/change';
// 上传图片
const imageUpload = '/api/public/images/upload';

// 添加错题
const adderrtopic = '/api/users/wrong-questions/add';
// 添加收藏 收藏试题
const topicCollect = '/api/users/questions/collect';
// 错题集列表
const errList = '/api/users/wrong-questions/';
// 错题集类型
const errType = '/api/users/wrong-question-types';
// 收藏集类型
const collectionType = '/api/users/collection-question-types';
// 收藏集试题列表
const collectionlist = '/api/users/collection-question/';
// 讲师入驻
const settle = '/api/users/teachers/join';
// 订单列表
const orderlist = '/api/users/orders/list';
// 取消订单
const cancelOrder = '/api/users/orders/cancel';
// 订单详情
const orderDetail = '/api/users/orders/';
// 删除订单
const delOrder = '/api/users/orders/delete';

// 收益记录列表
const incomelist = '/api/users/income-records/list';
// 提现记录列表
const withdrawlist = '/api/users/withdrawals/list';

// 登录
export function getLogin(data) {
  return request({
    url: loginUrl,
    method: 'post',
    data
  })
}
// 上传图片
export function uploadImage(data) {
  return request({
    url: imageUpload,
    method: 'post',
    data
  })
}
// 用户协议
export function getAgreement(data) {
  return request({
    url: agreementUrl,
    method: 'get',
    data
  })
}

// 隐私政策
export function getPrivacy(data) {
  return request({
    url: privacyUrl,
    method: 'get',
    data
  })
}
// 用户信息
export function getUserInfo(data) {
  return request({
    url: userInfo,
    method: 'get',
    data
  })
}
// 修改头像
export function changeAvaters(data) {
  return request({
    url: changeAvater,
    method: 'post',
    data
  })
}
export function editNickname(data) {
  return request({
    url: editNameUrl,
    method: 'post',
    data
  })
}
// 模拟考试信息
export function examsInfo(data) {
  return request({
    url: '/api/users/practice-exams/infos',
    method: 'get',
    data
  })
}
// 设置做题数
export function countSet(data) {
  return request({
    url: '/api/users/questions/count-set',
    method: 'post',
    data
  })
}
// 添加错题
export function addErrtopic(data) {
  return request({
    url: adderrtopic,
    method: 'post',
    data
  })
}
// 错题集类型
export function getErrType(data) {
  return request({
    url: errType,
    method: 'get',
    data
  })
}
// 取消所有收藏试题
export function delAllcollection(data) {
  return request({
    url: '/api/users/questions/all-collections/cancel',
    method: 'post',
    data
  })
}
// 取消所有错题试题
export function delAllwrongTopic(data) {
  return request({
    url: '/api/users/wrong-questions/clear',
    method: 'post',
    data
  })
}
// 错题集列表
export function getErrList(data) {
  return request({
    url: errList + data + '/list',
    method: 'get',
    // data
  })
}

// 添加收藏 收藏试题
export function addCollect(data) {
  return request({
    url: topicCollect,
    method: 'post',
    data
  })
}
// 收藏集类型
export function getCollectionType(data) {
  return request({
    url: collectionType,
    method: 'get',
    data
  })
}
// 收藏集试题列表
export function getCollectionlist(data) {
  return request({
    url: collectionlist + data + '/list',
    method: 'get',
    data
  })
}
// 所有收藏试题
export function getAllCollection(data) {
  return request({
    url: '/api/users/collection-question/all',
    method: 'get',
    data
  })
}
// 收藏类型试题
export function getTypeCollection(data1,data2) {
  return request({
    url: '/api/users/collection-question/'+data1 + '/questions',
    method: 'get',
    data:data2
  })
}
// 所有错题试题
export function getAllwrong(data) {
  return request({
    url: '/api/users/wrong-questions/all',
    method: 'get',
    data
  })
}
// 指定错题类型试题
export function getTypewrong(data1,data2) {
  return request({
    url: '/api/users/wrong-questions/'+ data1 +'/questions',
    method: 'get',
    data:data2
  })
}
// 讲师入驻
export function joinSettle(data) {
  return request({
    url: settle,
    method: 'post',
    data
  })
}

// 订单列表
export function getOrderlist(data) {
  return request({
    url: orderlist,
    method: 'get',
    // data
  })
}
// 取消订单
export function getCancelOrder(data) {
  return request({
    url: cancelOrder,
    method: 'post',
    data
  })
}

// 订单详情
export function getOrderDetail(data) {
  return request({
    url: orderDetail + data + '/details',
    method: 'get',
    // data
  })
}
// 删除订单
export function getDelOrder(data) {
	return request({
	  url: delOrder,
	  method: 'post',
	  data
	})
}

// 收益记录列表
export function getIncomelist(data) {
  return request({
    url: incomelist,
    method: 'get',
    data
  })
}
// 提现记录列表
export function getWithdrawlist(data) {
  return request({
    url: withdrawlist,
    method: 'get',
    data
  })
}

// 提现
export function getWithdraw(data) {
	return request({
	  url: '/api/users/withdraw',
	  method: 'post',
	  data
	})
}
// 提现手续费率
export function getWithdrawRate(data) {
	return request({
	  url: '/api/public/withdraw-rate',
	  method: 'get',
	  data
	})
}